<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('部门信息(有效)')"/>
    <th:block th:include="include :: layout-latest-css"/>
    <th:block th:include="include :: ztree-css"/>
    <th:block th:include="include :: container-css"/>
    <th:block th:include="include :: select2-css"/>
</head>
<body class="gray-bg">
<form id="user-form">
    <div class="ui-layout-center">
        <div class="container-div">
            <div class="row">
                <!-- 公司搜索栏 -->
                <div class="col-sm-12 search-collapse" id="compCondition">
                    <div class="select-list">
                        <ul>

                        </ul>
                    </div>
                </div>


                <!-- 公司表格DIV -->
                <div class="col-sm-12 select-table table-striped">
                    <table id="bootstrap-table" data-mobile-responsive="true"></table>
                </div>

            </div>
        </div>
    </div>
</form>

<th:block th:include="include :: footer"/>
<th:block th:include="include :: layout-latest-js"/>
<th:block th:include="include :: ztree-js"/>
<th:block th:include="include :: datetimepicker-js"/>

<script th:inline="javascript">
    var prefix = ctx + "dep/info";

    $(function () {
        var panehHidden = false;
        if ($(this).width() < 800) {
            panehHidden = true;
        }
        $('body').layout({initClosed: panehHidden, west__size: 350});
        queryData();
    });

    //加载公司表格
    function queryData() {
        var columns = [];
        var depId = {field: 'depId', title: '序号'};
        var depCode = {field: 'depCode', title: '部门代码'};
        var title = {field: 'title', title: '部门名称'};
        var depAbbr = {field: 'depAbbr', title: '部门简称'};
        var DepGradeTitle = {field: 'DepGradeTitle', title: '部门级别'};
        var DepTypeTitle = {field: 'DepTypeTitle', title: '部门类型'};
        var compTitle = {field: 'compTitle', title: '所属公司'};
        var AdminIdTitle = {field: 'AdminIdTitle', title: '行政上级部门'};
        var funcationIdTitle = {field: 'funcationIdTitle', title: '职能上级部门'};
        var DirectorName = {field: 'DirectorName', title: '部门负责人'};
        var Director2Name = {field: 'Director2Name', title: '部门分管领导'};
        var DepCostTitle = {field: 'DepCostTitle', title: '成本中心'};
        var BZnum = {field: 'BZnum', title: '编制人数'};
        var EffectDate = {field: 'EffectDate', title: '成立日期'};
        var remark = {field: 'remark', title: '备注'};


        columns.push(depId, depCode,title,depAbbr,DepGradeTitle,DepTypeTitle,compTitle,AdminIdTitle);
        columns.push(funcationIdTitle,DirectorName,Director2Name,DepCostTitle,BZnum,EffectDate,remark);


        var options = {
            code: "depId",
            uniqueId: "depId",
            url: ctx + "dep/info/list?isDisabled=0",
            escape: true,
            showPageGo: true,
            rememberSelected: true,
            height: $(window).height() - 120,
            sortOrder: "desc",
            modalName: "部门信息",
            columns: columns
        };
        $.table.init(options);
    }


    //刷新公司表格
    function compRefresh() {
        $("#comp-table").bootstrapTable('refresh');
    }


    //导出公司信息
    function compExport() {
        var compCode = $("#compCode").val();
        var compGroup = $("#compGroup").val();
        var title = $("#title").val();
        var compGrade = $("#compGrade").val();
        var adminName = $("#adminName").val();

        $.ajax({
            cache: true,
            type: "POST",
            url: "/company/export",
            data: {
                "compCode": compCode,
                "compGroup": compGroup,
                "title": title,
                "compGrade": compGrade,
                "adminName": adminName
            },
            success: function (request) {
                window.location.href = ctx + "common/download?fileName=" + request.msg + "&delete=" + true;
            },
            error: function (XMLHttpRequest, textStatus, errorThrown) {
                alert("错误,请联系管理员,错误信息:" + textStatus);
            }
        });

    }
</script>


</body>
</html>